﻿namespace ctolua.Models
{
    /// <summary>
    /// 破坏物
    /// </summary>
    public class MDestructible
    {
        /// <summary>
        /// 破坏物实体
        /// </summary>
        public Destructible destructible { get; set; }
        /// <summary>
        /// 编号
        /// </summary>
        public int? key => this.destructible.api_get_key();
        /// <summary>
        /// 获取可破坏物类型
        /// </summary>
        /// <returns>可破坏物类型</returns>
        public int? type => game_api.get_dest_type(this.destructible);
        /// <summary>
        /// 预设 破坏物昵称
        /// </summary>
        public string default_name => game_api.get_dest_name_by_type(this.key);
        /// <summary>
        /// 预设 破坏物描述
        /// </summary>
        public string default_desc => game_api.get_dest_desc_by_type(this.key);
        /// <summary>
        /// 是否存在
        /// </summary>
        public bool? is_null => game_api.destructible_is_exist(this.destructible);
        /// <summary>
        /// 获取可破坏物类型的模型
        /// </summary>
        /// <returns>模型编号</returns>
        public int? model_key => game_api.get_model_key_of_dest_key(this.key);

        public MDestructible(Destructible destructible)
        {
            this.destructible = destructible;
        }
        public static MDestructible obj(Destructible destructible)
        {
            return new MDestructible(destructible);
        }
        /// <summary>
        /// 创建可破坏物
        /// </summary>
        /// <param name="location ">  位置   </param>
        /// <param name="dest_key ">  物品编号   </param>
        /// <param name="angle ">  面向角度   </param>
        /// <param name="size ">  大小   </param>
        /// <returns>创建出的可破坏物</returns>
        public MDestructible(Point location, int? dest_key, double angle, double? size)
        {
            this.destructible = game_api.create_destructible(location, dest_key, py.Fix32(angle), size);
        }
        /// <summary>
        /// 创建可破坏物
        /// </summary>
        /// <param name="dest_key ">  物品编号   </param>
        /// <param name="location ">  位置   </param>
        /// <param name="angle ">  面向角度   </param>
        /// <param name="scale_x ">  缩放x   1</param>
        /// <param name="scale_y ">  缩放y   1</param>
        /// <param name="scale_z ">  缩放z   1</param>
        /// <param name="height_offset ">  高度   0</param>
        /// <returns>创建出的可破坏物</returns>
        public MDestructible(int? dest_key, Point location, double angle, double? scale_x, double? scale_y, double? scale_z, double? height_offset)
        {
            this.destructible = game_api.create_destructible_new(dest_key, location, py.Fix32(angle), py.Fix32(scale_x), py.Fix32(scale_y), py.Fix32(scale_z), py.Fix32(height_offset));
        }
        /// <summary>
        /// 判断可破坏物是否在区域中
        /// </summary>
        /// <param name="area ">  区域   </param>
        /// <returns>布尔值</returns>
        public bool? is_dest_in_area(Area area) => game_api.is_dest_in_area(this.destructible, area);


    }
}
